import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ApiProperty } from '@nestjs/swagger';
import { Document } from 'mongoose';
import { UpdateProductDto } from 'src/modules/product/dto/update-product.dto';
import { RecordType } from 'src/utils/record-type.enum';

export type RecordDocument = Record & Document;

@Schema()
export class Record extends Document {
  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '对应商品',
    example: '商品对象',
  })
  product: UpdateProductDto;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '出售人',
    example: '小明',
  })
  name: string;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '出售日期',
    example: '2021-10-10 20:00:00',
  })
  time: Date;

  @Prop({
    required: true,
  })
  @ApiProperty({
    description: '记录类型',
    example: '0/1/2',
  })
  type: RecordType;
}

export const RecordSchema = SchemaFactory.createForClass(Record);
